library(tidyverse)
library(janitor)
library(jsonlite)
Key statistics on new and unplanned return attendances at Accident and Emergency (A&E) services across Scotland. The information presented includes trends in the number of attendances and admissions, and performance against the four hour waiting time standard.
a_and_a_url <- paste0("https://www.opendata.nhs.scot/api/3/action/datastore_search?resource_id=2a4adc0a-e8e3-4605-9ade-61e13a85b3b9&limit=15410")
a_and_e_json <- fromJSON(a_and_a_url, flatten = TRUE)
a_and_e <- a_and_e_json$result$records
head(a_and_e)
a_and_e %>%
glimpse()
## Rows: 15,410
## Columns: 26
## $ `_id` <int> 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1…
## $ Month <int> 200707, 200707, 200707, 200707, …
## $ Country <chr> "S92000003", "S92000003", "S9200…
## $ HBT <chr> "S08000015", "S08000015", "S0800…
## $ TreatmentLocation <chr> "A101H", "A111H", "A207H", "A210…
## $ DepartmentType <chr> "Minor Injury Unit or Other", "E…
## $ NumberOfAttendancesAggregate <int> 252, 5414, 92, 3530, 20, 105, 31…
## $ NumberOfAttendancesEpisode <int> NA, 5414, NA, 3530, NA, NA, NA, …
## $ NumberOfAttendancesEpisodeQF <chr> "z", "", "z", "", "z", "z", "z",…
## $ NumberMeetingTargetAggregate <int> 252, 5290, 92, 3355, 20, 105, 31…
## $ NumberMeetingTargetEpisode <int> NA, 5290, NA, 3355, NA, NA, NA, …
## $ NumberMeetingTargetEpisodeQF <chr> "z", "", "z", "", "z", "z", "z",…
## $ DischargeDestinationAdmissionToSame <int> NA, 1985, NA, 106, NA, NA, NA, N…
## $ DischargeDestinationAdmissionToSameQF <chr> "z", "", "z", "", "z", "z", "z",…
## $ DischargeDestinationOtherSpecialty <int> NA, 11, NA, 0, NA, NA, NA, NA, 1…
## $ DischargeDestinationOtherSpecialtyQF <chr> "z", "", "z", "", "z", "z", "z",…
## $ DischargeDestinationResidence <int> NA, 3374, NA, 3369, NA, NA, NA, …
## $ DischargeDestinationResidenceQF <chr> "z", "", "z", "", "z", "z", "z",…
## $ DischargeDestinationTransfer <int> NA, 44, NA, 8, NA, NA, NA, NA, 2…
## $ DischargeDestinationTransferQF <chr> "z", "", "z", "", "z", "z", "z",…
## $ DischargeDestinationUnknown <int> NA, 0, NA, 47, NA, NA, NA, NA, 1…
## $ DischargeDestinationUnknownQF <chr> "z", "", "z", "", "z", "z", "z",…
## $ AttendanceGreater8hrs <int> NA, 26, NA, 3, NA, NA, NA, NA, 0…
## $ AttendanceGreater8hrsQF <chr> "z", "", "z", "", "z", "z", "z",…
## $ AttendanceGreater12hrs <int> NA, 24, NA, 1, NA, NA, NA, NA, 0…
## $ AttendanceGreater12hrsQF <chr> "z", "", "z", "", "z", "z", "z",…
a_and_e %>%
clean_names()
a_and_e %>%
distinct(Month) %>%
arrange()